package com.tool.btn;

import org.come.Jpanel.ZhuShouJpanel;
import org.come.thread.TimeControlRunnable;
import org.come.until.CutButtonImage;

import java.awt.event.MouseEvent;

public class ZhuShouBtn extends MoBanBtn {

    private boolean isStart = false;
    private final ZhuShouJpanel zhuShouJpanel;
    private final int caozuo;

    public ZhuShouBtn(String iconpath, int type, int caozuo, ZhuShouJpanel zhuShouJpanel) {
        super(iconpath, type);
        this.caozuo = caozuo;
        this.zhuShouJpanel = zhuShouJpanel;
    }

    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {
        if (caozuo == 0) {
            isStart = !isStart;
            try {
                if (isStart) {
                    setIcons(CutButtonImage.cuts("Inkimg/button/B459.png"));
                    TimeControlRunnable.addAllTask(zhuShouJpanel.getAllActive());
                    TimeControlRunnable.isVip = true;
                } else {
                    setIcons(CutButtonImage.cuts("Inkimg/button/B458.png"));
                    TimeControlRunnable.removeScript(true);
                    TimeControlRunnable.isVip = false;
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    public void setStart(boolean isStart) {
        this.isStart = isStart;
        try {
            if (isStart) {
                setIcons(CutButtonImage.cuts("Inkimg/button/B459.png"));
            } else {
                setIcons(CutButtonImage.cuts("Inkimg/button/B458.png"));
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
